Hi,
Im trying to create a bit rotate function for a "hexadecimal calculator". I found a code in wikipedia that seems to work:
However, i want to rewrite it on my own but i want to know the formula behind it, like what is "CHAR_BIT" for? Is it the number of bits the answer will be shown?Code:unsigned int x; unsigned int y; /* ... */ y = (x << shift) | (x >> (sizeof(x)*CHAR_BIT - shift));